#{extends '/template/main.html' /}
<script type="text/javascript" src="/public/js/echarts.min.js" ></script>
<div id="yesterdayStatistics" style="width:100%; height:700px;"></div>

<script type="text/javascript">
    var dom = document.getElementById("yesterdayStatistics");
    var myChart = echarts.init(dom);
    getType();
    function getType() {
        option = {
            color: ['#3398DB'],
            tooltip : {
                trigger: 'axis',
                axisPointer : {            // 坐标轴指示器，坐标轴触发有效
                    type : 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
                }
            },
            grid: {
                left: '3%',
                right: '4%',
                bottom: '3%',
                containLabel: true
            },
            xAxis : [
                {
                    type : 'category',
                    data: ['昨日新增顾客数', '昨日新增商户数', '昨日访问顾客数', '昨日被访问商品数', '昨日成交订单数', '昨日成交金额', '投诉订单数'],
                    axisTick: {
                        alignWithLabel: true
                    }
                }
            ],
            yAxis : [
                {
                    type : 'value'
                }
            ],
            series : [
                {
                    label: {
                        show:true,
                        formatter:'{b}:{@score}'
                    },
                    type:'bar',
                    barWidth: '60%',
                    data:(function(){
                        var arr=[];
                        $.ajax({
                            type : "get",
                            async : false, //同步执行
                            url : "/BS0034/admin/report/saleYesterdayStatistics",
                            success : function(data) {
                                console.log("data",data)
                                var newUserCount = data.newUserCount;
                                var newMerCount = data.newMerCount;
                                var userRecordCount = data.userRecordCount;
                                var proRecordCount = data.proRecordCount;
                                var orderCount = data.orderCount;
                                var sumAcountOrder = data.sumAcountOrder;
                                var tsOrderCount = data.tsOrderCount;
                                arr.push(newUserCount);
                                arr.push(newMerCount);
                                arr.push(userRecordCount);
                                arr.push(proRecordCount);
                                arr.push(orderCount);
                                if (data) {
                                    for(var i=0;i<data.sumAcountOrder.length;i++){
                                        console.log(data.sumAcountOrder[i].sumAmount.replace(/,/g,''));
                                        arr.push(data.sumAcountOrder[i].sumAmount.replace(/,/g,''));
                                    }
                                }
                                arr.push(tsOrderCount);

                            },
                            error : function(errorMsg) {
                                alert("不好意思，图表请求数据失败啦!");
                                myChart.hideLoading();
                            }
                        })
                        return arr;
                    })()
                }
            ]
        };
        myChart.setOption(option)
    }
</script>